using System;
using System.ComponentModel;

namespace TimeToGo.Formatters
{
    public abstract class DurationFormatterBase : IDurationFormatter
    {
        private DurationPostfixMixin PostFix { get; set; }
        protected string FormatString { get; set; }
        
        protected DurationFormatterBase(string formatString)
        {
            PostFix = new DurationPostfixMixin();
            FormatString = formatString;
        }

        public abstract string Name { get; }

        public string GetDuration(TimeSpan duration)
        {
            return FormatDuration(duration) + PostFix.Get(duration.Ticks);
        }

        protected abstract string FormatDuration(TimeSpan duration);
    }
}